class Solution {
    public int minimumDeleteSum(String s1, String s2) {
        int m = s1.length();
        int n = s2.length();
        s1 = " " + s1;
        s2 = " " + s2;
        char[] chArr1 = s1.toCharArray();
        char[] chArr2 = s2.toCharArray();
        int[][] dp = new int[m + 1][n + 1];
        // 初始化
        dp[0][0] = 0;
        for(int j = 1; j <= n; j++) dp[0][j] = dp[0][j - 1] + (int)chArr2[j];
        for(int i = 1; i <= m; i++) dp[i][0] = dp[i - 1][0] + (int)chArr1[i];
        for(int i = 1; i <= m; i++){
            for(int j = 1; j <= n; j++){
                if(chArr1[i] == chArr2[j]) dp[i][j] = dp[i - 1][j - 1];
                else dp[i][j] = Math.min(dp[i - 1][j] + (int)chArr1[i], dp[i][j - 1] + (int)chArr2[j]);
            }
        }
        return dp[m][n];
    }
}